package com.zhongwang.mms.module.buy.service;

import com.zhongwang.mms.module.buy.dao.PurchaseDao;
import com.zhongwang.mms.module.buy.model.PlanDetailsModel;
import com.zhongwang.mms.module.buy.model.PlanDetailsOpenModel;
import com.zhongwang.mms.module.buy.model.Types;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 项目 服务层
 * @Author: China.kxx
 * @Date: 2020/04/03 17:07
 */
@Service
public class PlanDetailsService {
    @Autowired
    private PurchaseDao purchaseDao;

    /**
     * 根据条件查询项目
     *
     * @param planDetailsModel 查询条件
     * @return 项目列表数据
     */
    public List<PlanDetailsModel> planDetail(PlanDetailsModel planDetailsModel) {
        List<PlanDetailsModel> planDetailList = null;
        try {
             planDetailList = purchaseDao.purchaseDetails(planDetailsModel);
        }catch (Exception e){
            e.printStackTrace();
        }
        return planDetailList;
    }

    private List<PlanDetailsModel> getPlanDetailListByRppTypeId(PlanDetailsModel planDetailsModel, Types types) {
        planDetailsModel.setRppTypeId(types.getId());
        return purchaseDao.purchaseDetails(planDetailsModel);
    }

    public PlanDetailsModel projectDetail(String rppProjectCode) {
        return purchaseDao.projectSign(rppProjectCode);
    }

    public PlanDetailsModel projectExecutionStatus(String rppProjectCode) {
        return purchaseDao.projectProduction(rppProjectCode);
    }

    public PlanDetailsModel plansToTag(String rppProjectCode) {
        return purchaseDao.plannedQuantity(rppProjectCode);
    }

    public PlanDetailsModel materialNum(String rppProjectCode) {
        return purchaseDao.allNum(rppProjectCode);
    }

    /**
     * 计划变更
     *
     * @param planDetailsOpenModel
     * @return
     * @Date: 2020/04/24 16:07
     */

    public List<PlanDetailsOpenModel> alterationOpen(PlanDetailsOpenModel planDetailsOpenModel) {
        return purchaseDao.alterationOpen(planDetailsOpenModel);
    }

    /**
     * 库存指定
     *
     * @param planDetailsOpenModel
     * @return
     * @Date: 2020/04/25 09:35
     */
    public List<PlanDetailsOpenModel> appointOpen(PlanDetailsOpenModel planDetailsOpenModel) {
        List<PlanDetailsOpenModel> list = null;
        try {
            list = purchaseDao.appointOpen(planDetailsOpenModel);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }

    /**
     * 合报记录
     *
     * @param planDetailsOpenModel
     * @return
     * @Date: 2020/06/18 19:11
     */
    public List<PlanDetailsOpenModel> merPurchasingOpen(PlanDetailsOpenModel planDetailsOpenModel) {
        List<PlanDetailsOpenModel> list= null;
        try{
            list = purchaseDao.merPurchasing(planDetailsOpenModel);
        }catch (Exception e){
            e.printStackTrace();
        }
        return list;
    }

    /**
     * 出库记录
     *
     * @param planDetailsOpenModel
     * @return
     * @Date: 2020/04/25 09:35
     */
    public List<PlanDetailsOpenModel> warehouseOpen(PlanDetailsOpenModel planDetailsOpenModel) {
        return purchaseDao.warehouseOpen(planDetailsOpenModel);
    }

    /**
     * 查询分类和数量
     *
     * @param code           类型编码
     * @param rppProjectCode 项目编号
     * @return list
     */
    public List<Types> findTypes(Integer code, String rppProjectCode) {
        return purchaseDao.findTypes(code, rppProjectCode);
    }


    public List<PlanDetailsOpenModel> appointPOpen(PlanDetailsOpenModel planDetailsOpenModel) {
        return purchaseDao.appointPOpen(planDetailsOpenModel);
    }
}
